import store from '@/store'
import dayjs from '@/uni_modules/uview-ui/libs/util/dayjs.js'
import { getUserLog, setUserLog, removeUserLog } from '@/utils/auth'

// 必须引用后,再解构
const { getters } = store

const tomorrow = dayjs().add(1, 'day').format('YYYY-MM-DD')
const saveLog = getUserLog()
const brands = getters['brandChannel/brands']
const brand =  brands.length>0 ?  brands[0].id:''

/**
 * @example createRow 创建默认数据
 * @constant {String} typeId 产品类型ID
 * @constant {String} name 消费者姓名
 * @constant {String} phone 联系方式
 * @constant {String} country 省市区
 * @constant {String} address 详细地址
 * @constant {String} goodsModel 产品型号
 * @constant {String} brand 品牌ID 或 其他品牌名称
 * @constant {String} brandId 品牌ID
 * @constant {String} brandOther 其他品牌名称
 * @constant {String} channel 购买渠道ID 或 其他购买渠道
 * @constant {String} channelId 购买渠道ID
 * @constant {String} channelOther 其他购买渠道
 * @constant {String} faultType 故障类型
 * @constant {String} faultTypeId 故障类型ID
 * @constant {String} faultTypeOther 其他故障类型名称
 * @constant {String} date 期望上门日期
 * @constant {String} time 期望上门时间
 * @constant {String} info 备注
 * @return {Object}
 */
export const createRow = {
	typeId: '',
	name: '',
	phone: '',
	country: [],
	address: '',
	goodsModel: '',
	brand,
	// brandId: '',
	// brandOther: '',
	channel: '',
	// channelId: '',
	// channelOther: '',
	faultType: '',
	// faultTypeId: '',
	// faultTypeOther: '',
	date: tomorrow,
	time: '',
	info: '',
}

// 如果有保存记录，则合并
if (saveLog) Object.assign(createRow, saveLog)
export default createRow